#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXN = 1e6+9;

struct node
{
    ll st,ed,v,a;
}car[MAXN];


ll T,n,m,L,V,num_car = 0,num_t1 = 0;
int block[MAXN];
int vim[MAXN];


inline void init(){

    num_car = 0;
    num_t1 = 0;

    memset(vim,sizeof(vim),0);
    memset(block,sizeof(block),0);

    cin >> n >> m >> L >> V;

    ll flag = 0;
    for (ll i = 1; i<= n;i++){
        ll st,v_st,a_st;
        cin >> st >> v_st >> a_st;
        car[i].st = st;
        car[i].a = a_st;
        car[i].v = v_st;
    }

    for (ll i = 1; i<= m;i++){
        ll t;
        cin >> t;
        block[t] = 1;
    }


    return;
}

inline void solve(){
    for (ll i = 1; i<= n; i++){
        if (car[i].a == 0){
            if (car[i].v > V){
                num_car++;
                for(ll j = car[i].st;j<= L;j++){
                    if(block[j]){
                        vim[j] = 1;
                        break;
                    }
                }
            }
            
        }

        if (car[i].a > 0){
            if (sqrt((2*car[i].a*(L-car[i].st)) + (car[i].v*car[i].v)) > V){
                num_car++;
                for(ll j = car[i].st;j<=L;j++){
                    ll vv = sqrt(2*car[i].a*(j-car[i].st) + car[i].v*car[i].v);
                    if(block[j]&& (vv > V)){
                        vim[j] = 1;
                        break;
                    }
                }
            }
            
        }
            
        if (car[i].a < 0){
            if (car[i].v > V){
                car[i].ed = car[i].st + ((V*V - (car[i].v*car[i].v))/(2*car[i].a));
                for(ll j = car[i].st;j<= car[i].ed;j++){
                    if (block[j]){
                        vim[j] = 1;
                        num_car++;
                        break;
                    }
                }
            }
            
        }
    }

    for (ll i = 1; i<= L; i++){
        if (vim[i]){
            num_t1++;
        }
    }

    return;
}

int main(){


    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> T;

    while(T--){
        init();
        memset(car,sizeof(car),0);
        solve();

        cout << num_car <<" "<< m-num_t1 << endl;
    }


    return 0;
}